package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.Courseregistrations;
import com.ruoyi.system.service.ICourseregistrationsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 课程报名信息Controller
 * 
 * @author 张英旺
 * @date 2024-02-27
 */
@RestController
@RequestMapping("/system/courseregistrations")
public class CourseregistrationsController extends BaseController
{
    @Autowired
    private ICourseregistrationsService courseregistrationsService;

    /**
     * 查询课程报名信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:courseregistrations:list')")
    @GetMapping("/list")
    public TableDataInfo list(Courseregistrations courseregistrations)
    {
        startPage();
        List<Courseregistrations> list = courseregistrationsService.selectCourseregistrationsList(courseregistrations);
        return getDataTable(list);
    }

    /**
     * 导出课程报名信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:courseregistrations:export')")
    @Log(title = "课程报名信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Courseregistrations courseregistrations)
    {
        List<Courseregistrations> list = courseregistrationsService.selectCourseregistrationsList(courseregistrations);
        ExcelUtil<Courseregistrations> util = new ExcelUtil<Courseregistrations>(Courseregistrations.class);
        util.exportExcel(response, list, "课程报名信息数据");
    }

    /**
     * 获取课程报名信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:courseregistrations:query')")
    @GetMapping(value = "/{registrationId}")
    public AjaxResult getInfo(@PathVariable("registrationId") Long registrationId)
    {
        return success(courseregistrationsService.selectCourseregistrationsByRegistrationId(registrationId));
    }

    /**
     * 新增课程报名信息
     */
    @PreAuthorize("@ss.hasPermi('system:courseregistrations:add')")
    @Log(title = "课程报名信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Courseregistrations courseregistrations)
    {
        return toAjax(courseregistrationsService.insertCourseregistrations(courseregistrations));
    }

    /**
     * 修改课程报名信息
     */
    @PreAuthorize("@ss.hasPermi('system:courseregistrations:edit')")
    @Log(title = "课程报名信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Courseregistrations courseregistrations)
    {
        return toAjax(courseregistrationsService.updateCourseregistrations(courseregistrations));
    }

    /**
     * 删除课程报名信息
     */
    @PreAuthorize("@ss.hasPermi('system:courseregistrations:remove')")
    @Log(title = "课程报名信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{registrationIds}")
    public AjaxResult remove(@PathVariable Long[] registrationIds)
    {
        return toAjax(courseregistrationsService.deleteCourseregistrationsByRegistrationIds(registrationIds));
    }
}
